package com.lxk.concurrency.example.immutable;

import java.util.Collections;
import java.util.Map;

import com.google.common.collect.Maps;
import com.lxk.concurrency.annoations.ThreadSafe;

@ThreadSafe
public class ImmutableExample2 {

	private static Map<Integer, Integer> map = Maps.newHashMap();

	static {
		map.put(1, 2);
		map.put(3, 4);
		map.put(5, 6);

		// 不允许 map 被做修改
		map = Collections.unmodifiableMap(map);
	}

	public static void main(String[] args) {

		map.put(1, 3);

		System.out.println(map);

	}

}
